using System.Collections.Generic;
using System.Linq;
using System.Windows;

namespace Pdf2epub.Model
{
    public class ContentBlockCollection : BaseCollection<ContentBlock>
    {
        public Chapter[] Chapters
        {
            get
            {
                List<Chapter> chapters = (from block in this where block.HtmlTag == HtmlReplacementTag.H1 select block.Chapter).ToList();
                return chapters.Distinct().ToArray();
            }
        }

        public ContentBlock[] this[Chapter chapter]
        {
            get { return this.Where(block => block.Chapter == chapter).ToArray(); }
        }

        public new void Clear()
        {
            Application.Current.Dispatcher.Invoke(() => base.Clear());
        }
    }
}